package io.renren.controller;

import io.renren.common.utils.R;
import io.renren.config.HttpClientUtils;
import io.renren.config.TLSSigAPIv2;
import io.renren.config.UrlReqUtil;
import io.renren.config.RandomUtil;
import io.renren.entity.*;
import io.renren.service.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;


/**
 * 我的界面
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/api")
public class MyMineController {

	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	@Autowired
	UsersService usersService;

	@Autowired
	DoctorService doctorService;

    @Autowired
    HealthheadlineService healthheadlineService;

    @Autowired
    InterrogationuserService interrogationuserService;

    @Autowired
    EvaluateService evaluateService;

    @Autowired
    CollectionService collectionService;

    @Autowired
    FeedbackService feedbackService;

    @Autowired
    ChatService chatService;

    @Autowired
    QuestionbankService questionbankService;


	/**
	 * 用户登陆
	 * @param code
	 * @param headimgurl 用户头像
	 * @param nickname 用户昵称
	 * @return
	 */
	@RequestMapping("/login")
	@ResponseBody
	public R login(@RequestParam("code")String code, @RequestParam("headimgurl")String headimgurl, @RequestParam("nickname")String nickname) {
		if(code ==null){
			return R.error("code不能为空");
		}else if(headimgurl ==null){
			return R.error("用户头像不能为空");
		}else if(nickname ==null){
			return R.error("用户昵称不能为空");
		}else{

			String urlopenid = "https://api.weixin.qq.com/sns/jscode2session?appid=wx9668eeadf7d439b2&secret=4b96ab88ef4cf03551509ffc7fa72b94&js_code="+code+"&grant_type=authorization_code";
			JSONObject json = HttpClientUtils.httpRequest(urlopenid,"GET",null);
			String openid = json.getString("openid");
			UsersVOEntity users = usersService.getUserInfoByOpenid(openid);

			if(users!=null){
				users.setHeadimg(headimgurl);
				users.setUsername(nickname);
				usersService.updateById(users);
			}else{
				String val = "";
				Random random = new Random();
				for (int i = 0; i < 10; i++) {
					val += String.valueOf(random.nextInt(10));
				}

				users = new UsersVOEntity();
				users.setCreatetime(new Date());
				users.setOpenid(openid);
				users.setHeadimg(headimgurl);
				users.setUsername(nickname);
				users.setHealthsn(val+users.getId());
				usersService.save(users);
			}
            String sign = new TLSSigAPIv2(1400242796,"8b60a61d8f490a17b5f8a1e9579735be157941e4a5d1f1f8e173cb27e767a34c")
                    .genSig("wenzhenadmin",604800);

            String account_import = "https://console.tim.qq.com/v4/im_open_login_svc/account_import?sdkappid=1400242796&identifier=wenzhenadmin&usersig="+sign+"&random=99999999&contenttype=json";
            String param = "{\"Identifier\":\""+nickname+"\",\"Nick\":\""+nickname+"\",\"FaceUrl\":\""+headimgurl+"\"}";
            JSONObject jsonObject = HttpClientUtils.httpRequest(account_import,"POST",param);
            if(jsonObject.getInt("ErrorCode")!=0){
                return R.error("账号导入失败");
            }else{
                return R.ok().put("userid",users.getId()).put("openid",openid);
            }

		}

	}

    /**
     * 用户信息
     * @param userid
     * @return
     */
    @RequestMapping("/user")
    @ResponseBody
    public R user(@RequestParam("userid")Integer userid) {
        if(userid ==null){
            return R.error("用户id不能为空");
        }else{
            UsersVOEntity user = usersService.getById(userid);
            if(user!=null){
                return R.ok().put("headimg",user.getHeadimg())
                        .put("username",user.getUsername()).put("id",user.getId())
                        .put("healthSn",user.getHealthsn());
            }else{
                return R.ok("找不到该用户");
            }

        }

    }


	/**
	 * 首页医生咨询
	 * @return
	 */
	@RequestMapping("/doctorConsultation")
	@ResponseBody
	public R doctorConsultation() {
		List<DoctorVOEntity> list = doctorService.getDoctorList();
		if(list!=null && list.size()>0){
			JSONArray array = new JSONArray();
			for(DoctorVOEntity entity:list){
				JSONObject object = new JSONObject();
				object.put("id",entity.getUserid());
				object.put("headimg",entity.getHeadimg());
				object.put("username",entity.getUsername());
				object.put("num",entity.getServicenum());
				object.put("rate",entity.getFavorablerate());
                object.put("longitude",entity.getLongitude());
                object.put("latitude",entity.getLatitude());
				array.add(object);
			}
			return R.ok().put("data",array);
		}else{
			return R.ok("没有医生信息");
		}

	}


    /**
     * 首页医生咨询更多
     * @return
     */
    @RequestMapping("/doctorConsultationMore")
    @ResponseBody
    public R doctorConsultationMore() {
        List<DoctorVOEntity> list = doctorService.getDoctorList();
        if(list!=null && list.size()>0){
            JSONArray array = new JSONArray();
            for(DoctorVOEntity entity:list){
                JSONObject object = new JSONObject();
                object.put("id",entity.getUserid());
                object.put("headimg",entity.getHeadimg());
                object.put("username",entity.getUsername());
                object.put("num",entity.getServicenum());
                object.put("rate",entity.getFavorablerate());
                object.put("longitude",entity.getLongitude());
                object.put("latitude",entity.getLatitude());
                array.add(object);
            }
            return R.ok().put("data",array);
        }else{
            return R.ok("没有医生信息");
        }

    }

	/**
	 * 首页健康头条
	 * @return
	 */
	@RequestMapping("/healthHeadLine")
	@ResponseBody
	public R healthHeadLine() {
		List<HealthheadlineEntity> list = healthheadlineService.getHeadLineList();
		if(list!=null && list.size()>0){
			JSONArray array = new JSONArray();
			for(HealthheadlineEntity entity:list){
				JSONObject object = new JSONObject();
				object.put("id",entity.getId());
				object.put("img",entity.getImgurl());
				object.put("content",entity.getContent());
				if(entity.getUserid()!=null){
				    UsersVOEntity user = usersService.getDoctorInfo(entity.getUserid());
				    if(user!=null){
                        object.put("headimg",user.getHeadimg());
                        object.put("username",user.getUsername());
                    }

                }

				array.add(object);
			}
			return R.ok().put("data",array);
		}else{
			return R.ok("没有医生信息");
		}

	}

    /**
     * 健康头条详情
     * @param id 健康头条id
     * @return
     */
    @RequestMapping("/healthHeadLineDetail")
    @ResponseBody
    public R healthHeadLineDetail(@RequestParam("id")Integer id) {
        if(id == null){
            return R.error("头条id不能为空");
        }else{
            HealthheadlineEntity entity = healthheadlineService.getById(id);
            if(entity !=null){

                return R.ok().put("answer",entity.getAnswer());
            }else{
                return R.ok("找不到该头条信息");
            }
        }

    }

    /**
     * 我的问诊
     * @param userid 用户id
     * @return
     */
    @RequestMapping("/myInterrogation")
    @ResponseBody
    public R myInterrogation(@RequestParam("userid")Integer userid) {
        if(userid == null){
            return R.error("用户id不能为空");
        }else{
            List<InterrogationuserEntity> list = interrogationuserService.myInterrogation(userid);
            if(list!=null && list.size()>0){
                JSONArray array = new JSONArray();
                for(InterrogationuserEntity entity:list){
                    JSONObject object = new JSONObject();
                    object.put("id",entity.getId());
                    object.put("time",sdf.format(entity.getCreatetime()));
                    /*EvaluateEntity evaluateEntity = evaluateService.getEvaluate(entity.getId());
                    if(evaluateEntity!=null){
                        object.put("isevaluate",true);
                    }else{
                        object.put("isevaluate",false);
                    }*/
                    if(entity.getDoctorid()!=null){
                        UsersVOEntity user = usersService.getDoctorInfo(entity.getDoctorid());
                        if(user!=null){
                            object.put("doctorid",entity.getDoctorid());
                           object.put("headimg",user.getHeadimg());
                           object.put("username",user.getUsername());
                        }
                    }
                    array.add(object);
                }
                return R.ok().put("data",array);
            }else{
                return  R.ok("没有数据");
            }
        }

    }

    /**
     * 查看评价
     * @param id 问诊id
     * @return
     */
    @RequestMapping("/getEvaluate")
    @ResponseBody
    public R getEvaluate(@RequestParam("id")Integer id) {
        if(id == null){
            return R.error("问诊id不能为空");
        }else{
            InterrogationuserEntity interrogationuserEntity = interrogationuserService.getById(id);
            if(interrogationuserEntity!=null){
                DoctorVOEntity doctor = doctorService.getDoctorById(interrogationuserEntity.getDoctorid());
                if(doctor!=null){
                    JSONObject object = new JSONObject();
                    object.put("id",doctor.getUserid());
                    object.put("doctorname",doctor.getUsername());
                    object.put("doctorheadimg",doctor.getHeadimg());
                    object.put("servicenum",doctor.getServicenum());
                    object.put("rate",doctor.getFavorablerate());
                    object.put("introduct",doctor.getIntroduct());
                    object.put("latitude",doctor.getLatitude());
                    object.put("longitude",doctor.getLongitude());

                    JSONArray array = new JSONArray();
                    List<EvaluateVOEntity> list = evaluateService.getDoctorEvaluate(interrogationuserEntity.getDoctorid());
                    if(list!=null && list.size()>0){
                        for(EvaluateVOEntity entity:list){
                            JSONObject json = new JSONObject();
                            json.put("username",entity.getUsername());
                            json.put("headimg",entity.getHeadimg());
                            json.put("star",entity.getStar());
                            json.put("content",entity.getEvaluate());
                            json.put("time",sdf.format(entity.getCreatetime()));
                            array.add(json);
                        }
                    }
                    object.put("evaluate",array);
                    return R.ok().put("data",object);
                }else{
                    return  R.ok("找不到该医生信息");
                }
            }else{
                return  R.ok("找不到该问诊信息");
            }

        }

    }

    /**
     * 获取医生信息
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/getDoctorInfo")
    @ResponseBody
    public R getDoctorInfo(@RequestParam("doctorid")Integer doctorid) {
        if(doctorid == null){
            return R.error("医生id不能为空");
        }else{
            DoctorVOEntity doctor = doctorService.getDoctorById(doctorid);
            JSONObject object = new JSONObject();
            if(doctor!=null) {

                object.put("id", doctor.getUserid());
                object.put("doctorname", doctor.getUsername());
                object.put("doctorheadimg", doctor.getHeadimg());
                object.put("servicenum", doctor.getServicenum());
                object.put("rate", doctor.getFavorablerate());
            }
            return R.ok().put("data",object);
        }

    }

    /**
     * 添加评价
     * @param interrogationid 问诊id
     * @param star 评论星级一到五
     * @param content 评论内容
     * @param anonymous 是否匿名 0 是 1 否
     * @return
     */
    @RequestMapping("/addEvaluate")
    @ResponseBody
    public R addEvaluate(@RequestParam("interrogationid")Integer interrogationid,@RequestParam("star")Integer star
            ,@RequestParam("content")String content,@RequestParam("anonymous")Integer anonymous) {
        if(interrogationid == null){
            return R.error("问诊id不能为空");
        }else if(star == null){
            return R.error("评论星级不能为空");
        }else if(content == null){
            return R.error("评论内容不能为空");
        }else if(anonymous == null){
            return R.error("是否匿名不能为空");
        }else{
            EvaluateEntity evaluateEntity = new EvaluateEntity();
            evaluateEntity.setAnonymous(anonymous);
            evaluateEntity.setCreatetime(new Date());
            evaluateEntity.setEvaluate(content);
            evaluateEntity.setInterrogationid(interrogationid);
            evaluateEntity.setStar(star);
            evaluateService.save(evaluateEntity);
            return R.ok();
        }

    }


    /**
     * 我的收藏
     * @param userid 用户id
     * @return
     */
    @RequestMapping("/myCollection")
    @ResponseBody
    public R myCollection(@RequestParam("userid")Integer userid) {
        if(userid == null){
            return R.error("用户id不能为空");
        }else{
            List<CollectionEntity> list = collectionService.myCollectionList(userid);
            if(list!=null && list.size()>0){
                JSONArray array = new JSONArray();
                for(CollectionEntity entity:list){
                    JSONObject object = new JSONObject();
                    object.put("doctorid",entity.getDoctorid());
                    if(entity.getDoctorid()!=null){
                        UsersVOEntity user = usersService.getDoctorInfo(entity.getDoctorid());
                        if(user!=null){
                            object.put("headimg",user.getHeadimg());
                            object.put("username",user.getUsername());
                        }
                    }
                    array.add(object);
                }
                return R.ok().put("data",array);
            }else{
                return  R.ok("没有数据");
            }
        }

    }


    /**
     * 添加收藏
     * @param userid 用户id
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/addCollection")
    @ResponseBody
    public R addCollection(@RequestParam("userid")Integer userid,@RequestParam("doctorid")Integer doctorid) {
        if(userid == null){
            return R.error("用户id不能为空");
        }else if(doctorid==null){
            return R.error("医生id不能为空");
        }else{
            CollectionEntity entity = new CollectionEntity();
            entity.setDoctorid(doctorid);
            entity.setUserid(userid);
            entity.setCreatetime(new Date());
            collectionService.save(entity);
            return R.ok();
        }

    }

    /**
     * 取消收藏
     * @param userid 用户id
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/cancelCollection")
    @ResponseBody
    public R cancelCollection(@RequestParam("userid")Integer userid,@RequestParam("doctorid")Integer doctorid) {
        if(userid == null){
            return R.error("用户id不能为空");
        }else if(doctorid==null){
            return R.error("医生id不能为空");
        }else{
            CollectionEntity entity = collectionService.getCollection(userid,doctorid);
            if(entity!=null){
                collectionService.removeById(entity.getId());
                return R.ok();
            }else{
                return  R.ok("找不到该收藏数据");
            }
        }

    }

    /**
     * 医生简介
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/doctorIntroduct")
    @ResponseBody
    public R doctorIntroduct(@RequestParam("doctorid")Integer doctorid,@RequestParam("userid")Integer userid) {
        if(doctorid == null){
            return R.error("医生id不能为空");
        }else{
            DoctorVOEntity doctor = doctorService.getDoctorById(doctorid);
            if(doctor!=null){
                JSONObject object = new JSONObject();
                object.put("id",doctor.getUserid());
                object.put("doctorname",doctor.getUsername());
                object.put("doctorheadimg",doctor.getHeadimg());
                object.put("servicenum",doctor.getServicenum());
                object.put("rate",doctor.getFavorablerate());
                object.put("introduct",doctor.getIntroduct());
                object.put("latitude",doctor.getLatitude()==null?"":doctor.getLatitude());
                object.put("longitude",doctor.getLongitude()==null?"":doctor.getLongitude());
                object.put("telphone",doctor.getTelphone());
                object.put("address",doctor.getAddress()==null?"":doctor.getAddress());
                object.put("hospital",doctor.getHospital()==null?"":doctor.getHospital());

                CollectionEntity entitys = collectionService.getCollection(userid,doctorid);
                if(entitys!=null){
                    object.put("iscollection",true);
                }else{
                    object.put("iscollection",false);
                }

                JSONArray array = new JSONArray();
                List<EvaluateVOEntity> list = evaluateService.getDoctorEvaluate(doctorid);
                if(list!=null && list.size()>0){
                    for(EvaluateVOEntity entity:list){
                        JSONObject json = new JSONObject();
                        json.put("username",entity.getUsername());
                        json.put("headimg",entity.getHeadimg());
                        json.put("star",entity.getStar());
                        json.put("content",entity.getEvaluate());
                        json.put("time",sdf.format(entity.getCreatetime()));
                        array.add(json);
                    }
                }
                object.put("evaluate",array);
                return R.ok().put("data",object);
            }else{
                return  R.ok("找不到该医生信息");
            }
        }

    }

    /**
     * 意见反馈
     * @param opinion 意见
     * @param imgurl 图片地址
     * @param telphone 手机号
     * @param userid 用户id
     * @return
     */
    @RequestMapping("/feedback")
    @ResponseBody
    public R feedback(@RequestParam("opinion")String opinion,@RequestParam("imgurl")String imgurl
            ,@RequestParam("telphone")String telphone,@RequestParam("userid")Integer userid) {
        if(opinion == null){
            return R.error("意见不能为空");
        }else if(userid == null){
            return R.error("用户id不能为空");
        }else{
            FeedbackEntity feedbackEntity = new FeedbackEntity();
            feedbackEntity.setOpinion(opinion);
            feedbackEntity.setCreatetime(new Date());
            feedbackEntity.setUserid(userid);
            if(StringUtils.isNotBlank(imgurl)){
                feedbackEntity.setImgurl(imgurl);
            }

            if(StringUtils.isNotBlank(telphone)){
                feedbackEntity.setTelphone(telphone);
            }
            feedbackService.save(feedbackEntity);
            return R.ok();
        }

    }

    /**
     * 上传图片
     * @param request
     * @return
     */
    @RequestMapping("/uploadImg")
    @ResponseBody
    public R uploadImg(HttpServletRequest request) {
        String img = null;
        String sn = null;
        try {
            sn = RandomUtil.generateString(16);
            img = UrlReqUtil.isContainsIMG(request);
            return R.ok().put("url",img).put("fmurl",UrlReqUtil.IMG_REQUEST_PATH+sn+".jpg");

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 添加聊天记录
     * @param sendid 消息发送人id
     * @param chat 消息内容
     * @param interrogatid 问诊id
     * @return
     */
    @RequestMapping("/addchat")
    @ResponseBody
    public R addchat(@RequestParam("sendid")Integer sendid,@RequestParam("chat")String chat
            ,@RequestParam("interrogatid")Integer interrogatid) {
        if(sendid == null){
            return R.error("消息发送人id不能为空");
        }else if(chat == null){
            return R.error("消息内容不能为空");
        }else{
            ChatEntity chatEntity = new ChatEntity();
            chatEntity.setMessage(chat);
            chatEntity.setInterrogatid(interrogatid);
            chatEntity.setSenderid(sendid);
            chatEntity.setSendtime(new Date());
            chatService.save(chatEntity);
            return R.ok();
        }

    }

    /**
     * 添加问诊信息
     * @param userid 用户id
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/addInterrogation")
    @ResponseBody
    public R addInterrogation(@RequestParam("userid")Integer userid,@RequestParam("doctorid")Integer doctorid) {
        if(userid == null){
            return R.error("用户id不能为空");
        }else if(doctorid == null){
            return R.error("医生id不能为空");
        }else{
            InterrogationuserEntity entity = new InterrogationuserEntity();
            entity.setCreatetime(new Date());
            entity.setDoctorid(doctorid);
            entity.setUserid(userid);
            interrogationuserService.save(entity);
            return R.ok().put("interrogatid",entity.getId());
        }

    }

    /**
     * 根据问题获取问题库
     * @param name 问题名称
     * @return
     */
    @RequestMapping("/questionBank")
    @ResponseBody
    public R questionBank(@RequestParam("name")String name) {
        if(name == null){
            return R.error("问题名称不能为空");
        }else{
            JSONArray array = new JSONArray();
            List<QuestionbankEntity> list = questionbankService.getQuestionByName(name);
            R doctor = recommendDoctor();
            if(list!=null && list.size()>0){
                for(QuestionbankEntity entity:list){
                    JSONObject json = new JSONObject();
                    json.put("id",entity.getId());
                    json.put("name",entity.getName()+"(点击查看)");
                    json.put("doctor",false);
                    json.put("doctorimg","");
                    json.put("doctorname","");
                    array.add(json);
                }

                if((int)doctor.get("code") != 500){
                    JSONObject jsons = new JSONObject();
                    jsons.put("name","点击此处咨询专家");
                    jsons.put("id",doctor.get("userid"));
                    jsons.put("doctor",true);
                    jsons.put("doctorimg",doctor.get("headimg"));
                    jsons.put("doctorname",doctor.get("username"));
                    array.add(jsons);
                }

            }else{
                if((int)doctor.get("code") != 500){
                    JSONObject jsons = new JSONObject();
                    jsons.put("name","点击此处咨询专家");
                    jsons.put("id",doctor.get("userid"));
                    jsons.put("doctor",true);
                    jsons.put("doctorimg",doctor.get("headimg"));
                    jsons.put("doctorname",doctor.get("username"));
                    array.add(jsons);
                }else{
                    JSONObject jsons = new JSONObject();
                    jsons.put("name","当前没有医生在线");
                    jsons.put("id","");
                    jsons.put("doctor",0);
                    jsons.put("doctorimg","");
                    jsons.put("doctorname","");
                    array.add(jsons);
                }
            }
            return R.ok().put("data",array).put("avatarUrl","http://img.newyx.net/android/201901/08/ab2b6725b0.png").put("content",name)
                    .put("date",sdf.format(new Date())).put("nickName","导诊助手").put("type","text");
        }

    }

    /**
     * 根据id获取问题库答案
     * @param id 问题库问题id
     * @return
     */
    @RequestMapping("/getQuestionBankById")
    @ResponseBody
    public R getQuestionBankById(@RequestParam("id")Integer id) {
        if(id == null){
            return R.error("问题库问题id不能为空");
        }else{
            QuestionbankEntity entity = questionbankService.getById(id);
            if(entity!=null){
                return R.ok().put("answer",entity.getAnswer());
            }else{
                return R.ok("找不到该问题");
            }

        }

    }

    /**
     * 推荐医生
     * @return
     */
    @RequestMapping("/recommendDoctor")
    @ResponseBody
    public R recommendDoctor() {
        String sign = new TLSSigAPIv2(1400242796,"8b60a61d8f490a17b5f8a1e9579735be157941e4a5d1f1f8e173cb27e767a34c")
                .genSig("wenzhenadmin",604800);


        String query_state = "https://console.tim.qq.com/v4/openim/querystate?sdkappid=1400242796&identifier=wenzhenadmin&usersig="+sign+"&random=99999999&contenttype=json";

        List<DoctorVOEntity> list = doctorService.getDoctor();
        if(list!=null && list.size()>0){
            String usernameArray = new String();
            for(int i=0;i<list.size();i++){
                usernameArray +="\""+list.get(i).getUsername()+"\"";
                if(i!=list.size()-1){
                    usernameArray +=",";
                }
            }
            String param = "{\"To_Account\":["+usernameArray+"]}";
            JSONObject jsonObject = HttpClientUtils.httpRequest(query_state,"POST",param);
            String name = "";
            if(!jsonObject.getString("ActionStatus").equals("FAIL")){
                JSONArray array = jsonObject.getJSONArray("QueryResult");
                for(int j=0;j<array.size();j++){
                    JSONObject jsonObject1 = array.getJSONObject(j);
                    if(!jsonObject1.getString("State").equals("Offline")){
                        name = jsonObject1.getString("To_Account");
                        break;
                    }
                }
            }

            if(!name.equals("")){
                UsersVOEntity entity = usersService.getUserInfoByUseraname(name);
                return R.ok().put("username",entity.getUsername()).put("headimg",entity.getHeadimg()).put("userid",entity.getId());
            }else{
                return R.error();
            }

        }else{
            return R.error();
        }



    }

    /**
     * 根据聊天id获取医生信息
     * @param username 医生聊天id
     * @return
     */
    @RequestMapping("/getDoctorInfoByName")
    @ResponseBody
    public R getDoctorInfoByName(@RequestParam("username")String username) {
        if(username == null){
            return R.error("医生聊天id不能为空");
        }else{
            DoctorVOEntity entity = doctorService.getDoctorByUserName(username);
            if(entity!=null){
                return R.ok().put("doctorid",entity.getUserid()).put("headimg",entity.getHeadimg());
            }else{
                return R.ok("找不到该医生");
            }

        }

    }

    /**
     * 修改医生服务人数
     * @param doctorid 医生id
     * @return
     */
    @RequestMapping("/modifyDoctorInfo")
    @ResponseBody
    public R modifyDoctorInfo(@RequestParam("doctorid")Integer doctorid) {
        if(doctorid == null){
            return R.error("医生id不能为空");
        }else{
            doctorService.modifyDoctorInfo(doctorid);
            return R.ok();

        }

    }
}
